﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XWord.Fundamental.Domain.Model;
using Luna.NHibernate;
using uNhAddIns.Adapters;

namespace XWord.Fundamental.Domain.Impl
{
    [PersistenceConversational(MethodsIncludeMode = MethodsIncludeMode.Implicit)]
    public class AlphabetModel : IAlphabetModel
    {
        private readonly IRepository<Alphabet> _alphabetRepository;
        private readonly IRepository<LCArticle> _lcArticleRepository;
        private readonly IRepository<Translate> _translateRepository;
        public AlphabetModel(IRepository<Alphabet> alphabetRepository)
        {
            _alphabetRepository = alphabetRepository;
        }

        public IList<Alphabet> GetAlphabetList()
        {
            return _alphabetRepository.GetAll().OrderBy(e => e.Name).ToList();
        }

        [PersistenceConversation(ConversationEndMode = EndMode.CommitAndContinue)]
        public void SaveAlphabet(Alphabet entity)
        {
            _alphabetRepository.MakePersistent(entity);
        }
    }
}
